package controller.KeyListeners;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.HashMap;

import javax.swing.KeyStroke;
import controller.Controller;
import model.playable.Playable;
import model.command.*;

public class NumberKeyListener extends KeyboardListener{
        private Controller controller;
        private NumberCommand command;
	public NumberKeyListener(Controller controller){
                setController(controller);
		keyBindings.put(KeyStroke.getKeyStroke(48,0), new Action(){
			//TODO
			//Code for 0 number command input
			public void perform() {
                            exe(0);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(49,0), new Action(){
			//TODO
			//Code for 1 number command input
			public void perform() {
                            exe(1);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(50,0), new Action(){
			//TODO
			//Code for 2 number command input
			public void perform() {
                            exe(2);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(51,0), new Action(){
			//TODO
			//Code for 3 number command input
			public void perform() {
                            exe(3);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(52,0), new Action(){
			//TODO
			//Code for 4 number command input
			public void perform() {
                            exe(4);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(53,0), new Action(){
			//TODO
			//Code for 5 number command input
			public void perform() {
                            exe(5);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(54,0), new Action(){
			//TODO
			//Code for 6 number command input
			public void perform() {
                            exe(6);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(55,0), new Action(){
			//TODO
			//Code for 7 number command input
			public void perform() {
                            exe(7);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(56,0), new Action(){
			//TODO
			//Code for 8 number command input
			public void perform() {
                            exe(8);
			}
		});
		keyBindings.put(KeyStroke.getKeyStroke(57,0), new Action(){
			//TODO
			//Code for 9 number command input
			public void perform() {
                            exe(9);
			}
		});
	}
        private void exe(int number){
            NumberCommand temp = (NumberCommand)((Command)command).clone();
            command.recieveNumber(number);
            controller.queueCommandInPlayable((Command)command);
            setCommand(temp);
        }
        private void setController(Controller controller){
            this.controller = controller;
        }
        public void setCommand(NumberCommand command){
            this.command = command;
        }
}
